// 2210.[栈dfs后序遍历四则运算] 表达式计算
// https://oj.rnd.huawei.com/problems/2210/details
// postorder_traversal
// 不存在除零,只包含+，-，*，/四,需要考虑负数
// 输入 9,3,5,-,2,*,+
// 只输出整数部分 5

#include <functional>
#include <hash_map>
#include <iostream>
#include <map>
#include <stack>
#include <string>
using namespace std;

int CalcExpression(const string &expression) {
  map<char, function<int(int, int)>> mapFunc{
      {'+', plus<int>()},
      {'-', minus<int>()},
      {'*', multiplies<int>()},
      {'/', divides<int>()},
  };
  stack<int> stk;
  string e = expression + ",";
  size_t start = 0;
  for (auto index = e.find(","); index != string::npos;
       index = e.find(",", start)) {
    string exp = e.substr(start, index - start);
    if (exp == "+" || exp == "-" || exp == "*" || exp == "/") {
      int nPost = stk.top();
      stk.pop();
      int nPre = stk.top();
      stk.pop();
      int nVal = mapFunc[exp[0]](nPre, nPost);
      // printf("push=%d\n", nVal);
      stk.push(nVal);
    } else {
      int nVal = stoi(exp);
      // printf("pushv=%d\n", nVal);
      stk.push(nVal);
    }
    start = index + 1;
  }
  return stk.top();
}

// ===========
inline string ReadLine() {
  string line;
  getline(cin, line);
  return line;
}

int main() {
  string expression = ReadLine();
  int result = CalcExpression(expression);
  cout << result << endl;
  return 0;
}
